<template>
  <div id="LeagueTotalMember" style="width: 100%; height: 55vh;padding: 10px"></div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "LeagueTotalMember",
  props:["LeagueTotalMemberData"],
  data() {
    return { data: this.LeagueTotalMemberData };
  },
  created() {
    // console.log(this.LeagueTotalMemberData)
  },
  mounted() {
    this.LeagueJS.getTotalPeople(info=>{
      console.log(info)
      let tempInfo = []
      info.map((i,j)=>{
        tempInfo.push(parseInt(i.leagueTotalPeople))
        j++
      })
      console.log(tempInfo)
      this.data = tempInfo
    })
    // this.renderEcharts();
  },
  watch:{
    "data":function () {
      console.log("检测")
      this.renderEcharts();
    }
  },
  methods:{
    renderEcharts() {
      if (!document.getElementById("LeagueTotalMember")) {
        return;
      }
      const chartDom = document.getElementById("LeagueTotalMember");
      const myChart = echarts.init(chartDom);
      let option;

      option = {
        title: {
          text: '联盟总人数变动'
        },
        tooltip: {
          trigger: 'axis',
          showContent: true
        },
        xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: this.data,
            type: 'line',
            smooth: true
          }
        ]
      };

      option && myChart.setOption(option);
    },
  }
}
</script>

<style scoped>

</style>
